package com.china08.yxyapi.util;

import java.util.Date;
import java.util.concurrent.TimeUnit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class RedisDownUtil {

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    public void set(String key) {
        redisTemplate.opsForValue().set("download:".concat(key), String.valueOf(new Date().getTime()), 10,
                TimeUnit.SECONDS);
    }

    public Long get(String key) {
        String value = redisTemplate.opsForValue().get("download:".concat(key));
        if (value == null) { return null; }
        return Long.parseLong(value);
    }

}
